﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "NdbObjectSchematic.h"
#include "IBaseGraphicsElementShapeValidiator.h"
#include "DbDataSchema.h"
#include "GmStructure.h"

namespace gcmp
{
    class IIstance;
    class StructureInstanceHoleValidator : public IBaseGraphicsElementShapeValidiator
    {
    public:
        virtual ~StructureInstanceHoleValidator() {}

    public:
        virtual bool ValidateBeforeCalculation(const IInstance* pInstance, std::wstring* pErrorMessage) const override;
    private:
        virtual std::wstring GetErrorMessage() const = 0;
        virtual bool IsStructureInstanceHole(const IInstance* pInstance) const = 0;
    };

    class StructureWallHoleValidator : public NdbObjectSchematic, public StructureInstanceHoleValidator
    {
        DBOBJECT_DATA_BEGIN_AND_QUICK_CAST_FROM(gcmp, StructureWallHoleValidator, gcmp::NdbObjectSchematic, D68915B7 - C6BD - 417F - B418 - AAA3F7704F43, gmstructure, gcmp::IBaseGraphicsElementShapeValidiator)
        DBOBJECT_DATA_END
    private:
        virtual std::wstring GetErrorMessage() const override 
        {
            return  GBMP_TR(L"墙洞位置超出墙的范围！");
        }
        virtual bool IsStructureInstanceHole(const IInstance* pInstance) const override;

    public: //实现NdbObject接口
        virtual NdbObject* GetTopOwnerObject() const override
        {
            return nullptr;
        }
    };

    class StructurePlateHoleValidator : public NdbObjectSchematic, public StructureInstanceHoleValidator
    {
        DBOBJECT_DATA_BEGIN_AND_QUICK_CAST_FROM(gcmp, StructurePlateHoleValidator, gcmp::NdbObjectSchematic, BBFBE67E - F8B8 - 4AD2 - 8E5F - 70B510BAFDE5, gmstructure, gcmp::IBaseGraphicsElementShapeValidiator)
        DBOBJECT_DATA_END
    private:
        virtual std::wstring GetErrorMessage() const override 
        {
            return  GBMP_TR(L"板洞不能完全超出板边界！");
        }
        virtual bool IsStructureInstanceHole(const IInstance* pInstance) const override;

    public: //实现NdbObject接口
        virtual NdbObject* GetTopOwnerObject() const override
        {
            return nullptr;
        }
    };
}
